#!/usr/bin/env bash

### databasefile

#if [ $1 =~ ?"db_[0-9].txt" ];then
#	echo "pas load $?"
#else
#	echo "load $1 $?"
#	db=$1
#	cat $db |  awk -F" " '{print $1"-"$3,$1,$2,$4,$5}' | sort -t' ' -k1,1 > "db_"$datefile".txt" #sort 1000G database file by chromosome and position
#fi


#test=`find db*`
#if [ $? -ne 0 ]; then
#echo "ce fichier n'est pas une image .jpg"
#else
#/usr/bin/convert $f -resize $geom ~/Images/thumbnails/$(basename $f .jpg)_$geom.png
#fi
#find db* > /dev/null
#if[ $? -ne 0 ];then

#find db_[0-9]*.txt > /dev/null
#if [ $? -ne 0 ];then
#	echo "load $1"
#	cat $1 |  awk -F" " '{print $1"-"$3,$1,$2,$4,$5}' | sort -t' ' -k1,1 > "db_"$datefile".txt" #sort 1000G database file by chromosome and position
#	db="db_"$datefile".txt"
#else
#	echo -e "\ndatabase(s) file(s) in your directory : "
#	find db_[0-9]*.txt 
#	echo -e "\nenter database filename to use or press \"c\" to load database's parameter's file"
#	read choice
#	if [ "$choice" == "c" ];then
#		cat $1 |  awk -F" " '{print $1"-"$3,$1,$2,$4,$5}' | sort -t' ' -k1,1 > "db_"$datefile".txt" #sort 1000G database file by chromosome and position
#	else
#		db=$choice
#	fi
#fi

# check for frequencies files date
#echo $(($1+0))
#if [ $(($1+0)) -eq 0  ];then
#	echo "The parameter \"date_of_freqfiles\" must be a date number  (e.g. frequencies_dataname_1232011.out, date_of_freqfiles : 1232011)"
#exit 3
#fi

# check for frequencies files date
#expr $1+ 0 1>/dev/null 2>&1 
#statut=$?  
#if test $statut -lt 2  
#then  
# echo "$var" numérique  
#fi 

#le "ou" en bash
#if [ "$1" == "" ]||[ "$2" == "" ]||[ "$3" == "" ]||[ "$4" == "" ]||[ $5 == "" ]  
#then

# check for frequencies files date
if [ -d $1 ];then
	echo "The first parameter (date_of_freqfiles) must be a date number  (e.g. frequencies_dataname_1232011.out, date_of_freqfiles : 1232011)"
	exit 2
else
	if [ $(($1+0)) -eq 0 ];then
		echo "The first parameter (date_of_freqfiles) must be a date number  (e.g. frequencies_dataname_1232011.out, date_of_freqfiles : 	1232011)"
	exit 2
	else
		datefreqfile=$1
	fi
fi
